package com.chinasofti.myjdk8datetime;

import java.text.ParseException;
import java.time.DayOfWeek;
import java.time.LocalDateTime;

public class JDK8DateDemo3 {
    public static void main(String[] args) throws ParseException {
        LocalDateTime localDateTime =
                LocalDateTime.of(2023,04,04,11,20,04);
        //获取年
        int year = localDateTime.getYear();
        System.out.println("year = " + year);
        //获取月
        int month = localDateTime.getMonthValue();
        System.out.println("month = " + month);
        //获取天

        int day = localDateTime.getDayOfMonth();
        System.out.println("月中的day = " + day);

        int dayOfYear = localDateTime.getDayOfYear();
        System.out.println("dayOfYear 365天中的第几天 = " + dayOfYear);

        //获取星期
        DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
        System.out.println("dayOfWeek = " + dayOfWeek);

        //获取分钟
        int minute = localDateTime.getMinute();
        System.out.println("minute = " + minute);
        //获取小时
        int hour = localDateTime.getHour();
        System.out.println("hour = " + hour);
    }


}
